package com.team;

import redis.clients.jedis.Jedis;

import java.util.ArrayList;

/**
 * @author 樊浩
 * @version 1.0
 * @description: TODO
 * @date 2021/3/5 11:21
 */
public class Test1 {
 public static void main(String[] args) throws InterruptedException {
  //1.创建Jedis对象
  Jedis jedis=new Jedis("localhost",6379);
  //2.使用jedis的方法操作Redis
  jedis.set("name","成龙");
  //设置有效时间
  jedis.expire("name",600);
  //获取键值
  String name=jedis.get("name");
  System.out.println(name);
  //查看剩余时间
  Thread.sleep(3000);
  System.out.println(jedis.ttl("name"));
  jedis.close();
 }
}
